import React from "react"

import useStore from "../context/useStore"
const PictureUpload:React.FC = ()=>{
    let {
        mine
    } = useStore()

    function fileChange(e:any){
        let file = e.target.files[0]
        let reader = new FileReader()
            reader.readAsDataURL(file)
            reader.onload = function(result){
                let data = {base64:this.result}
                console.log(result , data)
                mine.fileUpload((data as unknown as FormData)).then(res=>{
                    console.log(res)
                })
            }
    }

    return <div>
        <input type="file" onChange={fileChange} />
        PictureUpload
    </div>
}
export default PictureUpload